package zz.app.ustbgsmanager.fragments;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.Objects;

import zz.app.ustbgsmanager.R;
import zz.app.ustbgsmanager.adapters.TeachingAssessmentPagerAdapter;
import zz.app.ustbgsmanager.beans.teachingassessment.CourseAssessment;

/**
 * Created by zz on 2018/6/11 13:41.
 */
public class TeachingAssessmentFragment extends Fragment {

    private ViewPager viewPager;
    private TabLayout tabLayout;
    private TeachingAssessmentPagerAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_teachingassessment,container,false);
        viewPager=view.findViewById(R.id.viewpager_teachingassessment);
        tabLayout=view.findViewById(R.id.tabLayout);
        tabLayout.setupWithViewPager(viewPager);
        adapter=new TeachingAssessmentPagerAdapter(getContext(),requireFragmentManager());
        viewPager.setAdapter(adapter);

        return view;
    }

    public void setData(ArrayList<CourseAssessment> data) {
        adapter.setData(data);
    }
    public void clear(){
        if(adapter!=null)
        adapter.setData(new ArrayList<CourseAssessment>());
    }
}
